<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
import { ajax } from '@/api';
import { getToken } from '@/utils/auth.js';
import eventBus from '@/api/eventBus';
export default {
  name: 'App',
  data(){
    return {
      params:{
        token:getToken()
      },
      time:''
    }
  },
  methods:{
    //后台待审核数据
    getData(){
      ajax('checkStatus',this.params).then((res) => {
        if(res.data.code === 200){
          //审核 
          //实名认证
          localStorage.setItem('authCount',res.data.data.authCount);
          //银行卡
          localStorage.setItem('bankCount',res.data.data.bankCount);
          //项目待审核
          localStorage.setItem('movieCount',res.data.data.movieCount);
          //订单待发货
          localStorage.setItem('orderDeliveryCount',res.data.data.orderDeliveryCount);
          //项目待收尾款
          localStorage.setItem('orderTailConfirmCount',res.data.data.orderTailConfirmCount);
          //提现待处理
          localStorage.setItem('withdrawCount',res.data.data.withdrawCount);
          eventBus.$emit('number');
        }
      });
    },
    getNewData(){
        this.getData();
        this.time = setInterval(() => {
          this.getData();
        },30000);
    },
  },
  mounted(){
    eventBus.$on('refreshUserInfo', () => {
      if(getToken()){
        this.getNewData();
      }
    });
  }
}
</script>
